package com.woniuxy.oldobject.controller;

import com.woniuxy.oldobject.dto.RoomDto;
import com.woniuxy.oldobject.entity.Room;
import com.woniuxy.oldobject.entity.Roomtype;
import com.woniuxy.oldobject.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author： Brian
 * @Todo：
 * @Date： 2022/7/22 10:57
 * @Version： 1.0
 */
@RestController
@RequestMapping("/bed/room")
public class RoomController {
    @Autowired
    private RoomService roomService;

    /**
     * 查询房间管理列表
     */
    @PostMapping("/list")
    public List<Room> list(Room room) {
        List<Room> list = roomService.selectRoomList(room);
        return list;
    }

    /**
     * 查询所有房间类型
     *
     * @return
     */
    @GetMapping("/roomtypeList")
    public List<Roomtype> roomtypeList() {
        List<Roomtype> list = roomService.selectroomtypeList();
        return list;
    }


    /**
     * 获取房间管理详细信息
     */
    @GetMapping(value = "/{roomId}")
    public Room getInfo(@PathVariable("roomId") Long roomId) {
        Room room = roomService.selectRoomByRoomId(roomId);
        return room;
    }

    /**
     * 新增房间管理
     */
    @PostMapping("/insertRoom")
    public int add(@RequestBody RoomDto room) {
        return roomService.insertRoom(room);
    }

    /**
     * 修改房间管理
     */
    @PutMapping
    public int edit(@RequestBody RoomDto room) {
        return roomService.updateoom(room);
    }

    /**
     * 删除房间管理
     */
    @DeleteMapping()
    public int remove(@RequestBody RoomDto room) {
        return roomService.deleteRoomByRoomId(room);
    }
}
